#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 2e5 + 10;
ll a[N];
void solve()
{
    ll x;
    char c;
    cin >> x >> c;
    if(c=='*')
    {
        cout << x << " " << 1 << endl;
    }
    else if(c=='+')
    {
        cout << x << " " << 1 << endl;
    }
    else
        cout << x + 1 << " " << 1;
}
int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}